<template>
	<div style="width:100%;height:523px;background: #f3f3f3;padding-top:0.1px;">
		<div class="infoma" >

			<form class="myform">
				<div>
					<label>收货人姓名：</label>
					<input type="text" name="">
				</div>
				<div>
					<label>手机号码：</label>
					<input type="number" name="">
				</div>
				<div @click="show()">
					<label class="city-area">省市区：</label>
					<!-- <input type="text" name="" class="city" > -->
					<span class="provice" v-text="pro[f.p].name"></span>
					<span class="outlying" v-text="city[f.c].name"></span>
					<span class="distr" v-text="county[f.cc].name"></span>
				</div>
				<div>
					<label>街道地址：</label>
					<input type="text" name="">
				</div>
				<div class="street">
					<span class="check" @click = "change()">
						<img src="./images/check_no.png">
					</span>
					<span class="check2" v-if="disp" @click="change1()">
						<img src="./images/check_yes.png">
					</span>
					<span class="mo-adr">设为默认地址</span>
				</div>
			</form>
			<p class="save">保存</p>
			<div class="foot-bg"></div>
		</div>
		<!-- 省市区三级联动 -->
		<div class="bg-rg" v-if="flag">
				<div class="layer_box">
					<p class="chose-pro">选择省市区</p>
					<div class="container">
						<div class="row">
							<div class="col">
								<label>省份：</label>
								<select v-model="f.p" @change="selpro">
									<option :value="i" v-for="(v,i) in pro">{{v.name}}</option>
								</select>
							</div>
							<div class="col">
								<label>城市：</label>
								<select v-model="f.c" @change="selcity">
									<option :value="i" v-for="(v,i) in city">{{v.name}}</option>
								</select>
							</div>
							<div class="col">
								<label>区域：</label>
								<select v-model="f.cc" v-show="county.length>0" @change="result">
									<option :value="i" v-for="(v,i) in county">{{v.name}}</option>
								</select>
							</div>
						</div>
					</div>
					<p class="make-sure" @click="hide()">确定</p>
				</div>
		</div>
	</div>
</template>
<script>
import data from "./data";
	export default{
		data () {
			return{
				flag:false,
				disp:false,
				disp1:true,
				content:'北京市 北京市 东城区',
				data:data,
		        pro:"",
		        city:"",
		        county:"",
		        f:{
			        p:0,
			        c:0,
			        cc:0
		       	}
			}

		},
		created:function(){
			this.pro=this.data;
			this.city=this.pro[0]['child'];
			this.county=this.city[0]['child'];
			this.result();
			// console.log(this.pro);
		},
		 methods:{
	        show:function(){
	          	this.flag= true
	        },

	        change(){
	        	this.disp = true
	        },
	         change1(){
	        	this.disp = false
	        },
	        selpro:function(){
				this.city=this.pro[this.f.p]['child'];
				this.county=this.city[0]['child'];
				this.f.c=0;
				this.f.cc=0;
				this.result();
			},
			selcity:function(){
				this.county=this.city[this.f.c]['child'];
				this.f.cc=0;
				this.result();
			},
			result:function(){
				var re={
					pro:{id:this.pro[this.f.p].id,name:this.pro[this.f.p].name},
					city:{id:this.city[this.f.c].id,name:this.city[this.f.c].name},
					county:{id:this.county[this.f.cc].id,name:this.county[this.f.cc].name}
				};
				this.$emit("select",re);

			},
			hide(){
	        	this.flag = false;
	        }

      	}
	}
</script>
<style>
.bg-rg{
	width: 100%;
	height: 100%;
	position:absolute;
	left: 0;
	top: 0;
	background:rgba(0,0,0,0.5);
	z-index:100;
	/*display: none;*/
}
.layer_box{
	width: 94%;
	height: 218px;
	background: #FFF;
	position: fixed;
    top: 50%;
    left: 3%;
    margin-top: -130px;
    z-index: 200;
}
.layer_box>.chose-pro{
	padding: 0 20px;
    line-height: 34px;
    border-bottom: solid 1px #EEE;
    color: #444;
     font-size: 14px;
}
.container,.row{
	width: 290px;
	height: 123px;
	float: left;

}

.row>.col{
	width: 290px;
	height:40px;
	/*padding-left: 70px;*/
    line-height: 40px;
    margin:0px auto;
    border-bottom: solid 1px #eee;
    float: left;
}
.row>.col>select>option{
	color: black;
}
.city-area{
	margin-top: 7px;
}
.layer_box>.make-sure{
	background: #fe3355;
    color: #FFF;
    font-size: 18px;
    text-align: center;
    width: 75%;
    height: 40px;
    float: left;
    margin:10px auto;
    line-height: 40px;
    text-align: center;
    margin-left: 30px;
}
.row>.col>label{
    width: 60px;
    line-height: 40px;
    color: #444;
    margin-left: 20px;
    font-size: 14px;
    display:inline-block;
    float: left;

}
.row>.col>select{
	width: 202px;
	height: 40px;
	font-size: 14px;
	display: inline-block;
	border: 0;
	outline: none;
	color: #444;
	float: right;
	background: #fff;
}
.infoma{
	background: #FFF;
	margin:10px auto;
	width: 88%;
	height: 224px;
	padding-left: 10px;
	padding-right: 10px;
}
.myform{
	width:280px;
	height: 224px;
}
.myform>div{
	width: 280px;
	height: 34px;
	padding: 5px 0;
    line-height: 34px;
    border-bottom: solid 1px #EEE;
    font-size: 14px;
}
.myform>div>label{
	color: #AAA;
}
.myform>div>input{
	width: 187px;
	height: 34px;
	font-size: 14px;
	outline: 0;
    border: 0;
}
.provice,.outlying,.distr{
	/*width: 5.8rem;*/
	height: 34px;
	font-size: 14px;
	color: black;
	display: inline-block;
}
.street>.check{
	width: 20px;
	height: 19px;
	display: inline-block;
}
.check2{
	width: 20px;
	height: 19px;
	display: inline-block;
	position: absolute;
	left:20px;
}
.check2>img{
	width: 20px;
	height: 19px;
}
.street>.check>img{
	width: 20px;
	height: 19px;
}
.street>.mo-adr{
	font-size: 15px;
	color: #444;
	vertical-align: middle;
}
.save{
	width:70% ;
	height: 40px;
	line-height: 40px;
    margin: 50px auto;
    background: #fe3355;
    color: #FFF;
    font-size: 18px;
    text-align: center;
}
.foot-bg{
	width: 100%;
	height:45px ;
	background-color: #F8F8F8;
	position: absolute;
	left: 0;
	bottom: 0;
	z-index: 130;
}
</style>
